<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQiiLanguageTinyTable extends Migration
{
    /**
     * Schema table name to migrate
     * @var string
     */
    public $set_schema_table = 'qii_language_tiny';

    /**
     * Run the migrations.
     * @table qii_language_tiny
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->set_schema_table)) return;
        Schema::create($this->set_schema_table, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('tiny_id')->comment('ID');
            $table->unsignedSmallInteger('type_id')->default('0')->comment('类型');
            $table->unsignedInteger('source_id')->default('0')->comment('来源内容id');
            $table->unsignedInteger('create_date')->default('0')->comment('创建时间');
            $table->unsignedInteger('modified_date')->default('0')->comment('修改时间');

            $table->index(["modified_date"], 'modified_date');

            $table->index(["type_id"], 'type_id');

            $table->unique(["type_id", "source_id"], 'type_source_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {
       Schema::dropIfExists($this->set_schema_table);
     }
}
